package entities;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name="ordenesCompra")
public class OrdenCompra implements Serializable{
	
	@Transient  
	private static final long serialVersionUID = 1L;
	
	private Integer id;
	private List<ItemOrdenCompra> items;
	private Proveedor proveedor;
		
	public OrdenCompra(Proveedor proveedor) {
		super();
		this.proveedor = proveedor;
	}
	@Id 
    @GeneratedValue( strategy = GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public void setItems(List<ItemOrdenCompra> items) {
		this.items = items;
	}

	@OneToMany(cascade=CascadeType.ALL)
	public List<ItemOrdenCompra> getItems() {
		return items;
	}
	
	@ManyToOne
	@JoinColumn(name = "id_proveedor")
	public Proveedor getProveedor() {
		return proveedor;
	}
	public void setProveedor(Proveedor proveedor) {
		this.proveedor = proveedor;
	}
	
}
